package biz

import (
	"time"

	"github.com/go-kratos/kratos/v2/log"
)

// Exam 定义考试结构体
type Exam struct {
	ExamID      string    `gorm:"type:string(11);not null;primaryKey;column:exam_id;comment:考试ID" json:"exam_id"`
	ExamName    string    `json:"exam_name" gorm:"comment:考试名称"`
	ExamTime    string    `json:"exam_time" gorm:"comment:考试时间"`
	ExamContent string    `json:"exam_content" gorm:"comment:考试内容"`
	CreatedAt   time.Time `json:"created_at" gorm:"comment:创建时间"`
	UpdatedAt   time.Time `json:"updated_at" gorm:"comment:更新时间"`
	TeacherID   string    `json:"teacher_id" gorm:"comment:教师ID"`
}

// ExamRepo 定义考试服务接口
type ExamRepo interface {
	// CreateExam 创建考试
	CreateExam(request *CreateRequest) (*CreateResponse, error)

	// DeleteExam 删除考试
	DeleteExam(examID string) error

	// UpdateExam 修改考试信息
	UpdateExam(request *Exam) error

	// GetExamInfo 获取考试信息
	GetExamInfo(examID string) (*Exam, error)
}

type ExamUsecase struct {
	repo ExamRepo
	log  *log.Helper
}

// CreateExamRequest 请求格式
type CreateRequest struct {
	ExamName    string `json:"exam_name"`
	ExamTime    string `json:"exam_time"`
	ExamContent string `json:"exam_content"`
	TeacherID   string `json:"teacher_id"`
}

// CreateExamResponse 响应格式
type CreateResponse struct {
	Message string `json:"message"`
	ExamID  string `json:"exam_id"`
}

// GetExamResponse 响应格式
type GetResponse struct {
	ExamID      string `json:"exam_id"`
	ExamName    string `json:"exam_name"`
	ExamTime    string `json:"exam_time"`
	ExamContent string `json:"exam_content"`
	TeacherID   string `json:"teacher_id"`
}
